<!DOCTYPE html>
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/table_data_tables.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:01 GMT -->

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>合同信息</title>

    <link rel="shortcut icon" href="favicon.ico">
    <link href="__PUBLIC__/dist/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/dist/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/dist/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/dist/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <!-- Data Tables -->
    <link href="__PUBLIC__/dist/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="__PUBLIC__/dist/css/animate.min.css" rel="stylesheet">
    <link href="__PUBLIC__/dist/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="__PUBLIC__/dist/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>{$info ? '编辑' : '新增'}合同信息</h5>
                    </div>
                    <div class="ibox-content">
                        <form id="myform" role="form" class="form-horizontal m-t" method="post">
                            {if condition="$businesses_id eq 0"}
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">所属商家：</label>
                                <div class="col-sm-6">
                                    <select id="businesses_id" name="businesses_id" class="form-control" required>
                                        {foreach name="businesses" item="item"}
                                        {if condition="$item['id'] eq $info['businesses_id']"}
                                        <option value="{$item.id}" selected="selected">
                                            {$item.name}
                                        </option>
                                        {else/}
                                        <option value="{$item.id}">
                                            {$item.name}
                                        </option>
                                        {/if}
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            {else/}
                            <input type="hidden" name="businesses_id" value="{$businesses_id}">
                            {/if}
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">合同编号：</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="contract_no" name="contract_no" value="{$contract_no}"
                                        placeholder="请输入合同编号" required>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">合同类型：</label>
                                <div class="col-sm-6">
                                    <select id="mode_id" name="mode_id" class="form-control" required>
                                        {foreach name="modes" item="item"}
                                        {if condition="$item['id'] eq $info['mode_id']"}
                                        <option value="{$item.id}" selected="selected">
                                            {$item.name}
                                        </option>
                                        {else/}
                                        <option value="{$item.id}">
                                            {$item.name}
                                        </option>
                                        {/if}
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">租赁类型：</label>
                                <div class="col-sm-6">
                                    <select id="hire_mode" name="hire_mode" class="form-control"
                                        required>
                                        {foreach name="hire_modes" item="item"}
                                        {if condition="$item['id'] eq $info['hire_mode']"}
                                        <option value="{$item.id}" ind="{$item.config_value}" selected="selected">
                                            {$item.config_name}
                                        </option>
                                        {else/}
                                        <option value="{$item.id}" ind="{$item.config_value}">
                                            {$item.config_name}
                                        </option>
                                        {/if}
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">所属业务：</label>
                                <div class="col-sm-6">
                                    <select id="service_id" name="service_id" class="form-control" required>
                                        {foreach name="services" item="item"}
                                        {if condition="$item['id'] eq $info['service_id']"}
                                        <option value="{$item.id}" selected="selected">
                                            {$item.name}
                                        </option>
                                        {else/}
                                        <option value="{$item.id}">
                                            {$item.name}
                                        </option>
                                        {/if}
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">所属客户：</label>
                                <div class="col-sm-6">
                                    <select id="customer_id" name="customer_id" class="form-control" required>
                                        {foreach name="customers" item="item"}
                                        {if condition="$item['id'] eq $info['customer_id']"}
                                        <option value="{$item.id}" selected="selected">
                                            {$item.real_name}
                                        </option>
                                        {else/}
                                        <option value="{$item.id}">
                                            {$item.real_name}
                                        </option>
                                        {/if}
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">所属门店：</label>
                                <div class="col-sm-6">
                                    <select id="store_id" name="store_id" class="form-control" required>
                                        {foreach name="stores" item="item"}
                                        {if condition="$item['id'] eq $info['store_id']"}
                                        <option value="{$item.id}" selected="selected">
                                            {$item.name}
                                        </option>
                                        {else/}
                                        <option value="{$item.id}">
                                            {$item.name}
                                        </option>
                                        {/if}
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">选择车辆：</label>
                                <div class="col-sm-10" id="car_list">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <!--用途-->
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">联系人：</label>
                                <div class="col-sm-6">
                                    <input type="text" class="form-control" id="contactor_name" name="contactor_name"
                                        value="{$info.contactor_name}" placeholder="请输入联系人" required>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">开始日期：</label>
                                <div class="input-daterange input-group datepicker">
                                    <input type="text" class="form-control" id="start_time" name="start_time" value='{$start_time|date="Y-m-d",###}'
                                        placeholder="请输入开始日期">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">到期日期：</label>
                                <div class="input-daterange input-group datepicker">
                                    <input type="text" class="form-control" id="end_time" name="end_time" value='{$end_time|date="Y-m-d",###}'
                                        placeholder="请输入到期日期">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <!--服务相册-->
                            <div class="form-group draggable ui-draggable">
                                <label class="col-sm-2 control-label">合同资料：</label>
                                <div class="row" id="photoBox">
                                    <div class="col-md-2 " style="text-align: center">
                                        <a href="javascript:;" class="fa fa-plus-square-o" onclick="GetUploadify3(10,'','txt,xls,xlsx,doc,docx,pdf,ppt,jpg,png,gif,jpeg','contract_files','call_back2');"
                                            style="width: 100%;font-size: 155px;"></a>
                                    </div>
                                    <div class="col-md-2 photoModel" style="display:none">
                                        <div class="ibox-content text-center" style="border: 0;">
                                            <div class="m-b-sm">
                                                <img alt="contract_file" src="__PUBLIC__/dist/img/a8.jpg" style="max-width: 100%;max-height: 110px;">
                                            </div>
                                            <div class="text-center">
                                                <a href="javascript:;" class="btn btn-xs btn-white delImage" data-path="">
                                                    <i class="fa fa-trash-o"></i> 删除 </a>
                                            </div>
                                        </div>
                                    </div>
                                    {foreach name="contract_file_list" item="item"}
                                    <div class="col-md-2">
                                        <div class="ibox-content text-center" style="border: 0;">
                                            <div class="m-b-sm">
                                                {if condition="in_array($item['file_ext'],$img_ext_list)"}
                                                <img alt="contract_file" src="{$item.file_url}" style="max-width: 100%;max-height: 50px;">
                                                {else/}
                                                <img alt="contract_file" src="__PUBLIC__/dist/img/{$item.file_ext}.gif"
                                                    style="max-width: 100%;max-height: 50px;">
                                                {/if}
                                            </div>
                                            <div class="text-center">
                                                <a href="javascript:;" class="btn btn-xs btn-white delImage" data-path="{$item.file_url}">
                                                    <i class="fa fa-trash-o"></i> 删除 </a>
                                            </div>
                                        </div>
                                        <input type="hidden" name="contract_files[]" value="{$item.file_url}">
                                    </div>
                                    {/foreach}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <!--详情描述-->
                            <div id="tab-1" class="tab-pane">
                                <div class="panel-body">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">说明：</label>
                                        <div class="col-sm-10">
                                            <textarea name="remark" id="editor2">{$info.remark}</textarea>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group draggable ui-draggable">
                                <div class="col-sm-12 col-sm-offset-3">
                                    <input type="hidden" name="car_id" value="0">
                                    <input type="hidden" class="form-control" id="data_count" name="data_count" value="{$info.data_count}">
                                    <input type="hidden" name="updator_id" value="{$info.updator_id}">
                                    <input type="hidden" name="update_time" value="{$info.update_time}">
                                    <input type="hidden" name="creator_id" value="{$info.creator_id}">
                                    <input type="hidden" name="create_time" value="{$info.create_time}">
                                    <input type="hidden" name="id" value="{$info.id}">
                                    <button class="btn btn-primary" type="submit">保存内容</button>
                                    <button class="btn btn-white" type="button" onclick="javascript:history.go(-1);">取消</button>
                                </div>
                            </div>
                        </form>
                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="__PUBLIC__/dist/js/jquery.min.js?v=2.1.4"></script>
    <script src="__PUBLIC__/dist/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
    <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/libs/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/libs/ueditor/ueditor.all.min.js"> </script>
    <script src="__PUBLIC__/dist/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/libs/global.js?rnd=12345678"> </script>

    <script>
        UE.getEditor('editor2');
        $('#start_time').datepicker().on('changeDate', function (e) {
            //获取选取的开始时间
            var endTimeStart = $("#start_time").val();
            //设置开始时间
            $('#end_time').datepicker('setStartDate', endTimeStart);
        });
        $('#end_time').datepicker().on('changeDate', function (e) {
            //获取选取的开始时间
            var startTimeStart = $("#end_time").val();
            //设置开始时间
            $('#start_time').datepicker('setEndDate', startTimeStart);
        });
        // 上传服务相册回调函数
        function call_back2(paths) {
            var img_ext_arr = ['.jpg', '.png', '.gif', '.jpeg'];
            for (var i = 0; i < paths.length; i++) {
                var clone = $('.photoModel').clone(true);
                var file_split = paths[i].split('.');
                var file_ext = '.' + file_split[file_split.length - 1];
                if ($.inArray(file_ext, img_ext_arr) > -1) {
                    clone.find('img').attr('src', paths[i]);
                } else {
                    clone.find('img').attr('src', '/public/dist/img/' + file_ext.replace('.') + '.gif');
                }
                clone.find('.delImage').attr('data-path', paths[i]);
                clone.append('<input type="hidden" name="contract_files[]" value="' + paths[i] + '">');
                clone.removeClass('photoModel');
                $('#photoBox').append(clone.show());
            }
            if (paths.length > 0) {
                if ($('#contract_files-error').length > 0 && !$('#contract_files-error').hasClass('hide')) {
                    $('#contract_files-error').addClass('hide');
                }
            }
        }
        function select_store_fun() {
            var store_id = $('#store_id').val();
            $.ajax({
                type: 'GET',
                url: "{:Url('Contract/ajax_car_list')}",
                data: { store_id: store_id, contract_id: '{$contract_id}' },
                success: function (res) {
                    $('#car_list').html(res);
                    $('#car_list input[type=checkbox]').click(function () {
                        if ($('#car_ids-error').length > 0 && !$('#car_ids-error').hasClass('hide')) {
                            $('#car_ids-error').addClass('hide');
                        }
                    });
                }
            });
        }
        $('#store_id').change(function () {
            select_store_fun();
        });
        $().ready(function () {
            // 在键盘按下并释放及提交后验证提交表单
            $("#myform").validate({
                submitHandler: function (form) {
                    if ($('#car_list').find('input[type=checkbox]:checked').length <= 0) {
                        if ($('#car_ids-error').length <= 0) {
                            $('#car_list').append('<label id="car_ids-error" class="error" for="car_ids" style="display: inline-block;">请选择车辆</label>');
                        } else {
                            if ($('#car_ids-error').hasClass('hide')) {
                                $('#car_ids-error').removeClass('hide');
                                $('#car_ids-error').css('display', 'inline-block');
                            }
                        }
                        $('#car_list input[type=checkbox]:first').focus();
                        return false;
                    }
                    if ($('#photoBox').find('input[type=hidden]').length <= 0) {
                        if ($('#contract_files-error').length <= 0) {
                            $('#photoBox div:first').append('<label id="contract_files-error" class="error" for="contract_files" style="display: inline-block;">请选择合同资料</label>');
                        } else {
                            if ($('#contract_files-error').hasClass('hide')) {
                                $('#contract_files-error').removeClass('hide');
                                $('#contract_files-error').css('display', 'inline-block');
                            }
                        }
                        $('#photoBox div:first a').focus();
                        return false;
                    }
                    form.submit();
                },
                rules: {
                    contract_no: {
                        required: true,
                        rangelength: [20, 32]
                    },
                    contactor_name: {
                        required: true,
                        rangelength: [2, 32]
                    }
                },
                messages: {
                    contract_no: {
                        required: "请输入合同编号",
                        rangelength: "合同编号长度不能小于 20 个字母"
                    },
                    contactor_name: {
                        required: "请输入联系人",
                        rangelength: "联系人长度不能小于 2 个字母"
                    }
                }
            });
            select_store_fun();
        });
    </script>
</body>


<!-- Mirrored from www.zi-han.net/theme/hplus/table_data_tables.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:02 GMT -->

</html>